home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp95 / freyja_t.z / freyja_t / freyja.h < prev    next >
C/C++ Source or Header  |  1992-04-14  |  16KB  |  596 lines

  1. /* FREYJA.H -- Freyja Header File
  2.  
  3.     Written 1980 by Mark of the Unicorn, Inc.
  4.     Rewritten 1991 by Craig A. Finseth
  5.  
  6. */
  7.  
  8. /* -------------------- We Begin -------------------- */
  9.  
  10. #include "fgenlib.h"
  11.  
  12. #if defined(MSDOS)
  13. #if defined(MAIN)
  14. #define STACKSIZE    ((10 * 1024) / 16);
  15. int _stklen = STACKSIZE;
  16. #endif
  17. #endif
  18.  
  19. #if defined(BERK43) || defined(UNIXV)
  20. #define UNIX        1
  21. #endif
  22.  
  23. #if defined(UNIX)
  24. char *getenv();
  25. #endif
  26.  
  27. #if defined(SYSMGR)
  28. #undef CALC
  29. #endif
  30.  
  31. /* -------------------- Constants -------------------- */
  32.  
  33.     /* amount of time to delay for delayed echos -- this is a loop count*/
  34. #if defined(MSDOS)
  35. #define DELAYCOUNT    0
  36. #else
  37. #define DELAYCOUNT    1000
  38. #endif
  39.  
  40.     /* size of the largest terminal to handle */
  41. #if defined(MSDOS)
  42. #define ROWMAX        25
  43. #define COLMAX        80
  44. #else
  45. #define ROWMAX        132
  46. #define COLMAX        240
  47. #endif
  48.  
  49.     /* preference items */
  50. #define HOVERLAP    5        /* columns to overlap for h. scroll */
  51. #define VOVERLAP    2        /* lines to overlap for ^V */
  52. #define PREF_PCT    40        /* preferred row as a % 0-100 */
  53. #define MACROMAX    128        /* max size of a keybaord macro */
  54.  
  55.     /* universal global declarations */
  56. #define    FORWARD        1
  57. #define    BACKWARD    0
  58.  
  59.     /* file names for help */
  60. #if !defined(NOCALC)
  61. #define CALCULATOR_FILE    "fcalc.doc"
  62. #endif
  63. #define CMDLIST_FILE    "fcmdlist.doc"
  64. #define COPYING_FILE    "fcopying.doc"
  65. #define FSF_FILE    "ffsf.doc"
  66. #define INFO_FILE    "freyja.doc"
  67. #define LEAGUE_FILE    "fleague.doc"
  68. #define XREF_FILE    "fcmdxref.doc"
  69. #define TUTORIAL_FILE    "ftutoria.doc"
  70. #define WARRANTY_FILE    "fwarrant.doc"
  71.  
  72.     /* maximum limits */
  73. #define    STRMAX        40        /* size of a response */
  74. #define LINEBUFFSIZE    255        /* size of an output line buffer */
  75. #define SMALLBUFFSIZE    33
  76.  
  77. #define BIGBUFFSIZE    (FNAMEMAX)    /* largest of FNAMEMAX and previous
  78.                     buffer sizes */
  79. #define NUMBUFFERS    12        /* buffers */
  80.  
  81. #define ZCQ        '\021'        /* ^Q */
  82. #define ZCX        '\030'        /* ^X */
  83. #define ZCZ        '\032'        /* ^Z */
  84. #define SNL        '\037'        /* "soft" newline, ^_ */
  85.  
  86.     /* pseudo-key definitions */
  87. #define KEYNONE        (-1)        /* no valid key */
  88. #define KEYABORT    (-2)
  89. #define KEYQUIT        (-3)
  90.  
  91.     /* for visible grayspace */
  92. #if defined(UNIX)
  93. #define VIS_SPACE_CHAR    '.'
  94. #define VIS_TAB_CHAR    '>'
  95. #define VIS_NL_CHAR    '<'
  96. #endif
  97. #if defined(MSDOS)
  98. #define VIS_SPACE_CHAR    '\372'
  99. #define VIS_TAB_CHAR    '\020'
  100. #define VIS_NL_CHAR    '\021'
  101. #define KEYHELP        (0x100 + 59)
  102. #endif
  103.  
  104. /* -------------------- Configuration Settings -------------------- */
  105.  
  106. #define INI_FILENAME    "freyja.ini"
  107.  
  108. struct conf_buffer {
  109.     int left_margin;    /* indent column */
  110.     int right_margin;    /* fill column */
  111.     int tab_spacing;    /* tab stop spacing */
  112.     char fill;        /* filling mode */
  113.     };
  114.  
  115. struct conf_global {
  116.     char screen_type;    /* screen type */
  117.     char screen_size;    /* screen size */
  118.     char key_type;        /* keyboard input */
  119.     char special;        /* special handling */
  120.     char parameter_1;    /* parameter 1 */
  121.     int swap_size;        /* default swap area size in Kbytes */
  122.     int ESC_swap;        /* swap Esc and this char (27 for no swap) */
  123.     int CTX_swap;        /* swap ^X and this char (24 for no swap) */
  124.     char meta_handle;    /* bit 2^8 in a character */
  125.     FLAG wrap_allowed;    /* check for word wrap files */
  126.     FLAG vis_gray;        /* True if grayspace is visible, False if not*/
  127.     FLAG use_caret;        /* True if carat notation */
  128.     int language;        /* Output language */
  129.     FLAG skip_system;    /* True if system buffers should be skipped */
  130.     FLAG saving;        /* True if ^X ^S should save unmodified files */
  131.     };
  132.  
  133. struct conf {
  134.     struct conf_buffer d;
  135.     struct conf_global g;
  136.     };
  137.  
  138. #if defined(MAIN)
  139. struct conf c;
  140. #else
  141. extern struct conf c;
  142. #endif
  143.  
  144. /* -------------------- Windows -------------------- */
  145.  
  146. #define NUMWINDOWS    2
  147.  
  148. struct window {
  149.     FLAG visible;        /* is the window visible/in use? */
  150.     int top;        /* first line of window */
  151.     int bot;        /* last line of window */
  152.     struct mark *sstart;    /* mark at the start of the window */
  153.     struct mark *send;    /* mark at the end of the window */
  154.     FLAG isend;        /* is the end mark valid? */
  155.     struct mark *point;    /* the point */
  156.     int offset;        /* the horizontal offset */
  157.     };
  158.  
  159. #if defined(MAIN)
  160. struct window windows[NUMWINDOWS];
  161. struct window *cwin;        /* the current window */
  162. int num_windows;        /* number of windows being displayed */
  163. #else
  164. extern struct window windows[NUMWINDOWS];
  165. extern struct window *cwin;
  166. extern int num_windows;
  167. #endif
  168.  
  169. /* -------------------- Buffers -------------------- */
  170.  
  171. #define    PAGESIZE    1024        /* page size in bytes */
  172. #define    SWAPMAX        256        /* maximum number of pages */
  173. #define NUM_PHYS_PAGES    16        /* number of pages in memory */
  174.  
  175. #define    MAXMARK        (2 * NUMBUFFERS + 4 * NUMWINDOWS + 4)
  176.  
  177. struct virt_page {
  178.     struct virt_page *next;        /* chain of pages in buffer */
  179.     struct virt_page *prev;
  180.     char where;            /* where page is M-memory, S-swap,
  181.                     L-locked */
  182.     int page_num;            /* page number in the swap area */
  183.     int gap_start;            /* gap start */
  184.     int page_len;            /* page length */
  185.     };
  186.  
  187. struct mark {
  188.     struct virt_page *pptr;        /* page in the buffer */
  189.     struct buffer *bptr;        /* buffer the mark is in */
  190.     int mark_offset;        /* offset in the page */
  191.     FLAG is_mod;            /* screen mark modified flags */
  192.     };
  193.  
  194. struct buffer {
  195.     char fname[FNAMEMAX];        /* the file name */
  196.     struct conf_buffer c;        /* configuration parameters */
  197.     struct mark *mptr;        /* the mark */
  198.     struct virt_page *first;    /* describe the pages */
  199.     struct virt_page *last;
  200.     struct virt_page *point_page;    /* point's page number */
  201.     int point_offset;        /* offset within page */
  202.     int num_pages;            /* number of pages in buffer */
  203.     FLAG is_mod;            /* has the buffer been modified? */
  204. #ifdef UNIX
  205.     long file_time;
  206. #endif
  207.     };
  208.  
  209. #if defined(MAIN)
  210. struct buffer buffers[NUMBUFFERS];
  211. #else
  212. extern struct buffer buffers[NUMBUFFERS];
  213. #endif
  214.  
  215.     /* current buffer information */
  216. #if defined(MAIN)
  217. struct buffer *cbuf;            /* the curent buffer */
  218. struct mark *mark;            /* the current mark */
  219. #else
  220. extern struct buffer *cbuf;
  221. extern struct mark *mark;
  222. #endif
  223.  
  224.     /* system buffer support */
  225. #define IS_SYS(x)    (*(x) == '%')
  226. #define SYS_BUFFLIST    "%bufflist%"
  227. #define SYS_DIRED    "%dired%"
  228. #define SYS_HELP    "%help%"
  229. #define SYS_KILL    "%kill%"
  230. #define SYS_SCRATCH    "%scratch%"
  231.  
  232. /* -------------------- Globals -------------------- */
  233.  
  234. #if defined(MAIN)
  235. int lastkey;        /* the last command key given */
  236. int lasttable;        /* the last prefix table used */
  237. int key;        /* the current command key */
  238. int table;        /* the current command table */
  239.  
  240. int uarg;        /* command argument */
  241. FLAG isuarg;        /* was there an argument? */
  242. FLAG isrepeating;    /* are we on the second or later repetition? */
  243. FLAG doabort;        /* do we leave the editor? */
  244.  
  245. struct buffer *kill_buf;    /* kill buffer */
  246.  
  247. char stringarg[STRMAX];    /* last string entered */
  248. char filearg[FNAMEMAX];    /* last filename entered */
  249. #else
  250. extern int lastkey;
  251. extern int lasttable;
  252. extern int key;
  253. extern int table;
  254. extern int uarg;
  255. extern FLAG isuarg;
  256. extern FLAG isrepeating;
  257. extern FLAG doabort;
  258. extern struct buffer *kill_buf;
  259. extern char stringarg[STRMAX];
  260. extern char filearg[FNAMEMAX];
  261. #endif
  262.  
  263. /* -------------------- Routines -------------------- */
  264.  
  265.     /* buf.c */
  266.  
  267. FLAG BInit();        /* int swap_size */
  268. void BFini();        /* void */
  269. struct buffer *BBufCreate();    /* char *fname */
  270. void BBufDelete();    /* struct buffer *bptr */
  271. struct buffer *BBufFind();    /* char *name */
  272. void BBufGoto();    /* struct buffer *bptr */
  273. void BBufUnmod();    /* void */
  274. void BCharChange();    /* char new */
  275. void BCharDelete();    /* int amount */
  276. FLAG BFileRead();    /* void */
  277. FLAG BFileWrite();    /* void */
  278. void BFlush();        /* void */
  279. char BGetChar();    /* void */
  280. char BGetCharAdv();    /* void */
  281. int BGetCol();        /* void */
  282. long BGetLength();    /* struct buffer *bptr */
  283. long BGetLocation();    /* void */
  284. FLAG BInsChar();    /* char new */
  285. void BInsSpaces();    /* int amount */
  286. FLAG BInsString();    /* char *str */
  287. void BInsTabSpaces();    /* int amount */
  288. void BInvalid();    /* void */
  289. FLAG BIsAfterMark();    /* struct mark *mptr */
  290. FLAG BIsAtMark();    /* struct mark *mptr */
  291. FLAG BIsBeforeMark();    /* struct mark *mptr */
  292. FLAG BIsEnd();        /* void */
  293. FLAG BIsFree();        /* struct buffer *bptr */
  294. FLAG BIsMod();        /* struct buffer *bptr */
  295. FLAG BIsStart();    /* void */
  296. void BMakeColB();    /* int col */
  297. void BMakeColF();    /* int col */
  298. struct buffer *BMarkBuf(); /* struct mark *mptr */
  299. struct mark *BMarkCreate(); /* void */
  300. void BMarkDelete();    /* struct mark *mptr */
  301. FLAG BMarkIsMod();    /* struct mark *mptr */
  302. void BMarkSetMod();    /* struct mark *mptr */
  303. struct mark *BMarkScreen();    /* int row */
  304. void BMarkSwap();    /* struct mark *mptr */
  305. void BMarkToPoint();    /* struct mark *mptr */
  306. void BMoveBy();        /* int amount */
  307. void BMoveToEnd();    /* void */
  308. void BMoveToStart();    /* void */
  309. void BPointToMark();    /* struct mark *mptr */
  310. void BPopState();    /* void */
  311. void BPushState();    /* void */
  312. void BRegCopy();    /* struct mark *mptr, struct buffer *bptr */
  313. void BRegDelete();    /* struct mark *mptr */
  314. FLAG BSearchB();    /* char c1, char c2 */
  315. FLAG BSearchF();    /* char c1, char c2 */
  316.  
  317.     /* calc.c */
  318.  
  319. #if !defined(NOCALC)
  320. void UInit();        /* void */
  321. void UCalc();        /* void */
  322. char *UDescr();        /* int operation */
  323. void UEnter();        /* void */
  324. char *UHelp();        /* int operation */
  325. void ULoadMac();    /* void */
  326. int UNumOps();        /* void */
  327. void UPrintX();        /* void */
  328. void USetup();        /* FLAG iscomma, FLAG issep */
  329. #endif
  330.  
  331.     /* char.c */
  332.  
  333. void CCharB();        /* void */
  334. void CCharBD();        /* void */
  335. void CCharF();        /* void */
  336. void CCharFD();        /* void */
  337. void CCharTran();    /* void */
  338. void CLineA();        /* void */
  339. void CLineAED();    /* void */
  340. void CLineB();        /* void */
  341. void CLineE();        /* void */
  342. void CLineF();        /* void */
  343. void CLineFD();        /* void */
  344. void CScrnB();        /* void */
  345. void CScrnBOW();    /* void */
  346. void CScrnF();        /* void */
  347. void CScrnFOW();    /* void */
  348.  
  349.     /* date.c */
  350.  
  351. void DCal();        /* void */
  352. void DMove();        /* int amout */
  353. void DNext();        /* void */
  354. void DNow();        /* struct tm *tptr */
  355. int DOW();        /* long day */
  356. void DPrev();        /* void */
  357. void DSetup();        /* int weekstart, int datefmt, int timefmt */
  358. void DToDate();        /* struct tm *tptr, long day, int cal */
  359. long DToDayN();        /* struct tm *tptr, int cal */
  360. #if !defined(SYSMGR)
  361. void DXCal();        /* struct tm *tptr */
  362. #endif
  363.  
  364.     /* display.c */
  365.  
  366. void DInit1();        /* void */
  367. void DInit2();        /* void */
  368. void DFini();        /* void */
  369. void DEcho();        /* char *msg */
  370. void DEchoNM();        /* char *msg */
  371. void DError();        /* char *msg */
  372. void DIncrDisplay();    /* void */
  373. #if defined(MSDOS)
  374. void DJMenus();        /* int which */
  375. #endif
  376. void DLeft();        /* void */
  377. void DModeFlags();    /* void */
  378. void DModeLine();    /* void */
  379. void DNewDisplay();    /* void */
  380. int DPrefLine();    /* void */
  381. void DRight();        /* void */
  382. void DScreenRange();    /* void */
  383. void DTogVisGray();    /* void */
  384. void DView();        /* char *msg */
  385. void DWindGrow();    /* void */
  386. int DWindHeight();    /* void */
  387. void DWindOne();    /* void */
  388. void DWindSwap();    /* void */
  389. void DWindTog();    /* void */
  390. void DWindTwo();    /* void */
  391. void DWindTwoO();    /* void */
  392.  
  393.     /* file.c */
  394.  
  395. void FBufBeg();        /* void */
  396. void FBufDel();        /* void */
  397. void FBufEnd();        /* void */
  398. void FBufList();    /* void */
  399. void FBufNext();    /* void */
  400. void FBufPrev();    /* void */
  401. #if !defined(NOEXEC)
  402. void FCommand();    /* void */
  403. #endif
  404. void FDIRED();        /* void */
  405. void FFileFind();    /* void */
  406. void FFileRead();    /* void */
  407. void FFileSave();    /* void */
  408. void FFileWrite();    /* void */
  409. FLAG FMakeSys();    /* char *name, FLAG erase */
  410. int FPathOpen();    /* char *name, char *actualname */
  411.  
  412.     /* help.c */
  413.  
  414. void HHelp();        /* void */
  415.  
  416.     /* ini.c */
  417.  
  418. FLAG IniLoad();        /* char screen, int size */
  419.  
  420.     /* jaguar.c */
  421.  
  422. #if defined(MSDOS)
  423. void JInit(void);
  424. void JFini(void);
  425. #if !defined(SYSMGR)
  426. void JAppt();        /* void */
  427. void JComm();        /* void */
  428. void JDisEnd(void);
  429. void JDisStart(void);
  430. void JFiler();        /* void */
  431. void JGetDir(char *dname);
  432. int JGetKey(void);
  433. void JHPCalc();        /* void */
  434. char JIsKey(void);
  435. void JLotus();        /* void */
  436. void JMemo();        /* void */
  437. void JMenu();        /* void */
  438. void JPhone();        /* void */
  439. void JSetup();        /* void */
  440. #else
  441. void JDisEnd(void);
  442. void JDisStart(void);
  443. void JGetDate(int *year, int *mon, int *day);
  444. void JGetDir(char *dname);
  445. FLAG JGetFile(char *prompt, char *fname, FLAG usestar);
  446. int JGetKey(void);
  447. char JIsKey(void);
  448. void JMenu();        /* void */
  449. void JMsg(char *str);
  450. void JNoFini(void);
  451. void JPreAlloc(unsigned paras);
  452. #endif
  453. #endif
  454.  
  455.     /* key.c */
  456.  
  457. int KAsk();        /* char *msg */
  458. void KBegMac();        /* void */
  459. FLAG KDelayPrompt();    /* char *msg */
  460. void KEndMac();        /* void */
  461. void KFromBuf();    /* struct buffer *bptr */
  462. void KFromMac();    /* void */
  463. void KFromStr();    /* char *str, int len */
  464. int KGetChar();        /* void */
  465. int KGetStr();        /* char *msg, char *str, int len */
  466. char KIsKey();        /* void */
  467. int *KMacPtr();        /* void */
  468. FLAG KUArg();        /* int targ */
  469.  
  470.     /* misc.c */
  471.  
  472. void GoToGray();    /* FLAG isforward */
  473. void GoToNotGray();    /* FLAG isforward */
  474. FLAG IsGray();        /* void */
  475. FLAG IsNL();        /* void */
  476. FLAG IsWhite();        /* void */
  477. void MAbort();        /* void */
  478. void MCtrlX();        /* void */
  479. void MExit();        /* void */
  480. void MIns8();        /* void */
  481. void MInsChar();    /* void */
  482. void MMakeDelete();    /* void */
  483. void MNotImpl();    /* void */
  484. void MMeta();        /* void */
  485. void MQuote();        /* void */
  486. void MReplace();    /* void */
  487. void MReplaceQ();    /* void */
  488. void MSearchB();    /* void */
  489. void MSearchF();    /* void */
  490. void MUArg();        /* void */
  491. void MovePastB();    /* FLAG (*pred)() */
  492. void MovePastF();    /* FLAG (*pred)() */
  493. void MoveToB();        /* FLAG (*pred)() */
  494. void MoveToF();        /* FLAG (*pred)() */
  495. FLAG SearchNLB();    /* void */
  496. FLAG SearchNLF();    /* void */
  497.  
  498.     /* region.c */
  499.  
  500. void RDelWhite();    /* void */
  501. void RHardToSoft();    /* void */
  502. void RIndent();        /* void */
  503. void RKillToMark();    /* struct mark * mptr, FLAG isforward */
  504. void RLower();        /* void */
  505. void RMarkSet();    /* void */
  506. void RMarkSwap();    /* void */
  507. void ROutdent();    /* void */
  508. void RRegCopy();    /* void */
  509. void RRegDelete();    /* void */
  510. void RSoftToHard();    /* void */
  511. void RTabify();        /* void */
  512. void RUntabify();    /* void */
  513. void RUpper();        /* void */
  514. void RYank();        /* void */
  515.  
  516.     /* table.c */
  517.  
  518. char *TabDescr();    /* int key, int table */
  519. void TabDispatch();    /* int key, int table */
  520. char *TabHelp();    /* int key, int table */
  521. int TabTable();        /* int key, int table */
  522. FLAG TabIsDelete();    /* int key, int table */
  523. FLAG TabIsVMove();    /* int key, int table */
  524. int TabNumFunc();    /* void */
  525.  
  526.     /* term.c */
  527.  
  528. FLAG TInit();        /* void */
  529. void TFini();        /* void */
  530. void TAdjCol();        /* void */
  531. void TBell();        /* void */
  532. void TCLEOL();        /* void */
  533. void TClrScreen();    /* void */
  534. void TForce();        /* void */
  535. int TGetCol();        /* void */
  536. int TGetKey();        /* void */
  537. int TGetOffset();    /* void */
  538. int TGetRow();        /* void */
  539. int TGetWidth();    /* char c, int column */
  540. void THiOff();        /* void */
  541. void THiOn();        /* void */
  542. FLAG TIsKey();        /* void */
  543. int TMaxCol();        /* void */
  544. int TMaxRow();        /* void */
  545. char *TPrintChar();    /* char c, char *buf */
  546. void TPutChar();    /* char c */
  547. void TPutStr();        /* char *str */
  548. void TSetOffset();    /* int offset */
  549. void TSetPoint();    /* int row, int column */
  550.  
  551.     /* white.c */
  552.  
  553. void WDelFWhite();    /* void */
  554. void WDelWhite();    /* void */
  555. void WFixup();        /* struct conf_buffer *cptr */
  556. void WIndNext();    /* void */
  557. void WIndDel();        /* void */
  558. void WIndThis();    /* void */
  559. void WInsNL();        /* void */
  560. void WInsNLA();        /* void */
  561. void WJoinGray();    /* void */
  562. void WLineCenter();    /* void */
  563. void WPrintLine();    /* void */
  564. void WPrintMar();    /* void */
  565. void WPrintPos();    /* void */
  566. void WSetFill();    /* void */
  567. void WSetLeft();    /* void */
  568. void WSetRight();    /* void */
  569. void WSetTabs();    /* void */
  570.  
  571.     /* word.c */
  572.  
  573. void WCaseRotate();    /* void */
  574. void WNumB();        /* void */
  575. void WNumF();        /* void */
  576. void WNumMark();    /* void */
  577. void WParaB();        /* void */
  578. void WParaF();        /* void */
  579. void WParaFill();    /* void */
  580. void WParaMark();    /* void */
  581. void WSentB();        /* void */
  582. void WSentBD();        /* void */
  583. void WSentF();        /* void */
  584. void WSentFD();        /* void */
  585. void WWordB();        /* void */
  586. void WWordBD();        /* void */
  587. void WWordCap();    /* void */
  588. void WWordF();        /* void */
  589. void WWordFD();        /* void */
  590. void WWordLow();    /* void */
  591. void WWordTran();    /* void */
  592. void WWordUp();        /* void */
  593. void WWrap();        /* void */
  594.  
  595. /* end of FREYJA.H -- Freyja Header File */
  596.